using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class InkEffect : MonoBehaviour
{
    public float grappleCD=3.0f;//可设置的锚点CD
    private float grappleTimer;//计时器
    private void Start() 
    {
        grappleTimer=grappleCD;
    }
    void Update() 
    {
        if(grappleTimer>=grappleCD)//冷却完毕，可抓取
        {
            grappleTimer=grappleCD;//停止读秒
            GetComponent<BoxCollider2D>().enabled=true;//启用碰撞检测器
            GetComponent<Animator>().SetBool("splashed",false);//播放正常动画
        }
        else//锚点冷却中，不可抓取
        {
            grappleTimer+=Time.deltaTime;//开始读秒
            GetComponent<BoxCollider2D>().enabled=false;//停用碰撞检测器
        }
    }
    void OnTriggerEnter2D(Collider2D collision)
    {
        GameObject otherObject = collision.gameObject;//获取碰撞
            if (otherObject.CompareTag("Player"))//碰撞玩家
            {
                GetComponent<Animator>().SetBool("splashed",true);//播放炸开动画
                grappleTimer=0f;//进入cd
            }
    }
}
